package com.zyx.nettypro.netty.handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;

import java.util.List;

/**
 * @author Yaxi.Zhang
 * @since 2021/9/24 11:09
 */
public class MyByteToLongReplayingDecoder extends ReplayingDecoder<Void> {

    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        System.out.println("MyByteToLongReplayingDecoder 被调用");
        // 使用 ReplayingDecoder 无需判断传入流的长度
        out.add(in.readLong());
    }
}
